﻿using SqlSugar;
using Store.Manager.ERP.Common.Models;
using Store.Manager.ERP.Domain.Entities;
using Store.Manager.ERP.Domain.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Store.Manager.ERP.Infrastructure
{
    public class OrganizationRepository : Repository<Organization>,IOrganizationRepository
    {
        public OrganizationRepository(ISqlSugarClient db):base(db)
        {
            
        }
        public async Task<CommonResponse<Organization>> AddAsync(Organization entity)
        {
            var mod =  await base.InsertReturnEntityAsync(entity);
            return CommonResponse<Organization>.OK(mod);
        }
        public new async Task<bool> UpdateAsync(Organization entity)
        {
            return await base.UpdateAsync(entity);
        }
        public async Task<bool> DeleteAsync(string code)
        {
            return await base.DeleteByIdAsync(code);
        }
        public async Task<Organization> GetByIdAsync(string code)
        {
            return await base.GetByIdAsync(code);
        }

        public Task<List<Organization>> GetAllAsync()
        {
            return base.GetListAsync();
        }

        public async Task<bool> AddRangeAsync(List<Organization> organizations)
        {
            return await base.InsertRangeAsync(organizations);
        }
    }
}
